using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GameFrameworkLibraly.BaseObjects
{
    public class TextObject:SpriteObject
    {
        public SpriteFont Font { get; set; }

        public string Text { get; set; }

        
        public TextObject(MyGame game) : base(game)
        {
        }

        public TextObject(MyGame game, Vector2 position) : base(game, position)
        {
        }

        public TextObject(MyGame game, Vector2 position, SpriteFont font) : base(game, position)
        {
            Font = font;
        }

        public TextObject(MyGame game, Vector2 position, SpriteFont font, string text): this(game, position,font)
        {
            Text = text;
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if(Font!=null && !string.IsNullOrEmpty(Text))
            {
                spriteBatch.DrawString(Font,Text,Position,SpriteColor,Angle,Origin,Scale,SpriteEffects.None,LayerDepth);
            }
        }

        public override Rectangle BoundingBox
        {
            get
            {
                if(Font!=null && !string.IsNullOrEmpty(Text))
                {
                    Vector2 measureString = Font.MeasureString(Text);
                    return new Rectangle((int) (OriginX + PositionX), (int) (OriginY+PositionY), (int)measureString.X, (int)measureString.Y);
                }
                return new Rectangle();
            }
        }
    }
}
